﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.Model;
using System.Data;

namespace HZ.Supervise.Web.Message
{
    public partial class MessageDetail : System.Web.UI.Page
    {
        IBLL.IBLL_MessageTypeDetail ibllMessage = new BLL.BLL_MessageTypeDetail();
        string id;
        string _strTypeId;
        string _strMessageTypeDetailId;
        string _strSqlWhere;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["query"] = URLUtil.GetSuperviseQueryFromURL(Request);
                //MessageTypeDetail mess = (MessageTypeDetail)ViewState["query"];
                SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
                //_strMessageTypeDetailId = mess.MessageDetailId;
                //_strTypeId = mess.TypeId.ToString();
                _strSqlWhere = sq.SqlStringWhere;
                BindData(_strSqlWhere);
            }
        }
        ///// <summary>
        ///// 将此条信息设置为已查看
        ///// </summary>
        //void SetIsRead()
        //{
        //    if (id!=null)
        //    {
        //        ibllMessage.SetMessageIsRead(id);
        //    }
        //}

        void BindData(string _strSqlWhere)
        {
            if (!string.IsNullOrEmpty(_strSqlWhere))
            {
                int t = 0;
                //Model.Message message = new HZ.Supervise.Model.Message();
                //message.Id = id;
                //message.CreatTime = null;

                gvwMessageDetailList.DataSource = ibllMessage.GetMessageOrderDetail(_strSqlWhere, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
                gvwMessageDetailList.DataBind();
                AspNetPager1.RecordCount = t;
            }
            else
            {

            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            //ViewState["query"] = URLUtil.GetSuperviseQueryFromURL(Request);
            //SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
            //id = sq.MessageId;
            BindData(_strSqlWhere);
        }

        protected void gvwMessageDetailList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DirectByDetail")
            {
                GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                string orderName = (row.FindControl("lblOrderName") as Label).Text;
                string hospitalName = e.CommandArgument.ToString();
                Response.Redirect("Message.aspx?typeId=1&hospitalName=" + hospitalName + "&orderName=" + orderName);
            }
        }
    }
}

